"""
https://www.nowcoder.com/practice/119bcca3befb405fbe58abe9c532eb29
"""

# str1 = input()
str1 = "A10;S20;W10;D30;X;A1A;B10A11;;A10;"

loc_map = {
    "A": [],
    "S": [],
    "D": [],
    "W": [],
}


def main():
    for s in str1.split(";"):
        loc = s[:1]
        str_num = s[1:]
        if str_num.isdigit():
            loc_map[loc].append(int(str_num))

    return f'{sum(loc_map["D"]) - sum(loc_map["A"])},{sum(loc_map["W"]) - sum(loc_map["S"])}'


print(main())
